#include "character.h"

extern struct LCD lcd;

char p_random[5];
void charracter_init(void)
{
    // 初始化字库
    Font_init(lcd.fb_mem, lcd.width, lcd.height);
}

void random_code(void)
{
    Clean_Area(602, 278, 173, 95, 0xFFFFFF);
    p_random[0] = '0' + rand() % 10;
    p_random[1] = '0' + rand() % 10;
    p_random[2] = '0' + rand() % 10;
    p_random[3] = '0' + rand() % 10;

    int x[4] = {603, 660, 702, 734};
    int y[4] = {278, 318, 292, 312};
    int z[4] = {4, 3, 2, 3};
    char *p1 = (char *)malloc(sizeof(short));
    for (int i = 0; i < 4; i++)
    {
        // snprinf 自动添加函数
        snprintf(p1, sizeof(short) + 1, "%c\0", p_random[i]);
        printf("%s\n", p1);
        Display_characterX(x[i], y[i], strlen(p1) + 1, p1, z[i], 0x0);
    }
    free(p1);
}